/*
 * BinaryGeneticAlgorithmParameters.cpp
 *
 *  Created on: Oct 17, 2013
 *      Author: filipe
 */

#include <cstdlib>
#include "BinaryGeneticAlgorithmParameters.h"


BinaryGeneticAlgorithmParameters::BinaryGeneticAlgorithmParameters()
{
	num_individuals = 100;
	num_max_iteractions = 100;
	num_parameters_to_optimize = 1;
	mutation_probability = 0.1;

	max_permited_value = (double *) calloc (num_parameters_to_optimize, sizeof(double));
	min_permited_value = (double *) calloc (num_parameters_to_optimize, sizeof(double));

	SetMaxPermitedValue(1.0);
	SetMinPermitedValue(0.0);
}


BinaryGeneticAlgorithmParameters::BinaryGeneticAlgorithmParameters(int num_parameters)
{
	num_individuals = 100;
	num_max_iteractions = 100;
	num_parameters_to_optimize = num_parameters;
	mutation_probability = 0.1;

	max_permited_value = (double *) calloc (num_parameters_to_optimize, sizeof(double));
	min_permited_value = (double *) calloc (num_parameters_to_optimize, sizeof(double));

	SetMaxPermitedValue(1.0);
	SetMinPermitedValue(0.0);
}


BinaryGeneticAlgorithmParameters::~BinaryGeneticAlgorithmParameters()
{
	free(max_permited_value);
	free(min_permited_value);
}


void
BinaryGeneticAlgorithmParameters::SetMaxPermitedValue(double value)
{
	for (int i = 0; i < num_parameters_to_optimize; i++)
		max_permited_value[i] = value;
}


void
BinaryGeneticAlgorithmParameters::SetMinPermitedValue(double value)
{
	for (int i = 0; i < num_parameters_to_optimize; i++)
		min_permited_value[i] = value;
}

